#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

int var = 100;

int main(int argc, char const *argv[])
{
        pid_t pid = fork();
        if(pid == 0){
                printf("var = %d, child, pid = %d, ppid=%d\n", var, getpid(), getppid());
                var = 1001;
                printf("var = %d, child, pid = %d, ppid=%d\n", var, getpid(), getppid());
                sleep(3);
                printf("var = %d, child, pid = %d, ppid=%d\n", var, getpid(), getppid());
        } else if(pid > 0){
                sleep(1);
                printf("var = %d, father, pid = %d, ppid=%d\n", var, getpid(), getppid());
                var = 2000;
                printf("var = %d, father, pid = %d, ppid=%d\n", var, getpid(), getppid());
        }
        return 0;
}
